/**
 * 
 */
package org.istt.service;

import java.util.Date;
import java.util.List;

import org.istt.domain.AttachFileDetail;
import org.istt.domain.Exchange;
import org.istt.domain.File;
import org.istt.domain.FileManagement;
import org.istt.web.helper.ExtendedPaginatedList;

/**
 * @author Huy
 *
 */
public interface FileManager extends Manager<File, String> {
	
	/**
	 * Get list of file belongs to a category
	 * @param catId category ID
	 * @return list of file
	 */
	List<File> searchByCatId(Long catId);
	
	/**
	 * Get list of file with criteria as follows
	 * @param cateId category ID
	 * @param fromDate
	 * @param toDate
	 * @param paginatedList 
	 * @return list of file
	 */
	ExtendedPaginatedList search(Integer type, Long departmentId, Long fileStatusId, Long fieldId, Long cateId, Date fromDate, Date toDate, String fileId, String sender, ExtendedPaginatedList paginatedList);

	List<File> searchWithoutPagination(Long departmentId, Long fileStatusId, Long fieldId, Long cateId, Date fromDate, Date toDate, String fileId, String sender);

	/***
	 * Phuc vu cho Webservice
	 * @param cateId
	 * @param fromDate
	 * @param toDate
	 * @param fileId
	 * @param sender
	 * @return
	 */
	List<File> searchFile(Long cateId, Date fromDate, Date toDate, String fileId, String sender, int pageNum);
	
	List<File> searchTrans(Long fieldId, Long cateId, String fileId, String sender);
	
	/**
	 * add a file management to a new file
	 * @param f
	 * @param fmgr
	 */
	void addFileMgrToFile(File f, FileManagement fmgr);
	
	/**
	 * Get list of file with file identities
	 * @param fileIds 
	 * @return list of file
	 */
	List<List<Object>> searchByFileIds(String[] fileIds);
	
	/**
	 * Get list of file by status
	 * @param status 
	 * @param paginatedList 
	 * @return list of file
	 */
	ExtendedPaginatedList findByStatus(int status, ExtendedPaginatedList paginatedList);
	/**
	 * Get list of ordered exchange by fileId
	 * @param status 
	 * @return list of exchange
	 */
	List<Exchange> getExchangeByFileId(String fileId, Long userId);
	/**
	 * Get list of ordered fileManagement by fileId
	 * @param status 
	 * @return list of FileManagement
	 */
	List<FileManagement> getFileManagementByFileId(String fileId, String username);	
	
	/**
	 * 
	 * @param fileId
	 * @return
	 */
	List<AttachFileDetail> getAttachFileDetailByFileId(String fileId);

	/**
	 * Created on 2012.03.29 by Thond
	 * @param fileId
	 * @return
	 */
	List<AttachFileDetail> findAttachFileDetailByFileId(String fileId);
	
	/**
	 * 
	 * @param fileId
	 */
	void removeAttachFileDetail(String fileId);
	List<Object[]> getFileProcessVoucher(String fileId);
	/**
	 * NDTHO
	 * @param cateId
	 * @param fromDate
	 * @param toDate
	 * @return
	 */
	List<File> getFilesForReport(Long cateId,Long subCateId, Date fromDate, Date toDate);
	
	List<File> getFilesByNameAndCode(String fileCode,String sender);
	
	
	/**
	 * Get all the files were handled by user
	 * @param userId
	 * @param paginatedList
	 * @return the list of fileManagement
	 */
	ExtendedPaginatedList getFileByUser(Long userId, Date fromDate, Date toDate, ExtendedPaginatedList paginatedList);
	
	ExtendedPaginatedList findFileByApprover(Long approverId, Date fromDate, Date toDate, String status,String filterCondition, ExtendedPaginatedList paginatedList);
	
	int getTotalRecordByFilterCondition(Long approverId, Date fromDate, Date toDate,String status,String filterCondition);
	
	ExtendedPaginatedList findFileByDeparment(Long departmentId, String status, ExtendedPaginatedList paginatedList);
	
	boolean checkNewFileByApprover(Long userId,Date fromDate,Date toDate,boolean status);
	
	/**
	 * whether the current file management handed by user and file or not
	 * @param fileId the file identity
	 * @param username the user-name
	 * @return <code>true</code> if the user can move to next step, otherwise <code>false</code>
	 */
	boolean isAbleToNextStep(String fileId, String username);
	
	/**
	 * Get the max of the number field 
	 * @return the max of the number field
	 */
	int getMaxNumberNoOfFile(Long fieldId, int reportStartingPoint);
	
	/**
	 * Get number of file on the 13th of this month
	 * @return number of file
	 */
	int getNumberOfFileOnDateReport(Long fieldId, int reportStartingPoint);
	
	/***
	 * 
	 */
	ExtendedPaginatedList getHistoryByUser(Long userId,Date from, Date to, ExtendedPaginatedList paginatedList);
	
	
	List<File> getReceivedFileByDate(Long deptId, Date from, Date to);
	
	/**
	 * Remove all the files whose id is include in the parameters
	 * @param ids id parameter
	 */
	void remove(String[] ids);
	
	void removeAllFile();

	void removeAllDataTable();
	
	
}

 
